package com.czl.module_service.adapter

import android.os.Bundle
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.czl.base.binding.command.BindingCommand
import com.czl.base.binding.command.BindingConsumer
import com.czl.base.config.AppConstants
import com.czl.base.data.bean.tengyun.AssetHandleBean
import com.czl.module_service.R
import com.czl.module_service.databinding.ItemAssetHandleMyApplyBinding
import com.czl.module_service.fragment.assetHandle.AssetHandleMyApplyFragment

class AssetHandleMyApplyAdapter(private val fragment: AssetHandleMyApplyFragment) :
    BaseQuickAdapter<AssetHandleBean, BaseDataBindingHolder<ItemAssetHandleMyApplyBinding>>(
        R.layout.item_asset_handle_my_apply
    ) {

    override fun convert(
        holder: BaseDataBindingHolder<ItemAssetHandleMyApplyBinding>,
        item: AssetHandleBean,
    ) {
        holder.dataBinding?.run {
            if (item.parentCompanyName == null){
                item.parentCompanyName = ""
            }
            if (item.parentCompanyShortName == null){
                item.parentCompanyShortName = ""
            }
            data = item
            adapter = this@AssetHandleMyApplyAdapter
            executePendingBindings()
        }
    }

    val onItemClick: BindingCommand<Any> = BindingCommand(BindingConsumer {
        if (it is AssetHandleBean) {

            fragment.startContainerActivity(AppConstants.Router.Service.F_SERVICE_ASSET_HANDLE_APPLY_INFO, Bundle().apply {
                putSerializable("handleApplicationId", it.handleApplicationId)
                putSerializable("taskUserId", "")
            })
        }
    })
}
